home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / platforms and tools / installer / lockfile / setlockbit.c next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.1 KB  |  74 lines

  1. /*
  2.     File:        SetLockBit.c
  3.  
  4.     Contains:    Sample to demonstrate setting the file lock bit.  This action
  5.                 atom code resource must be called through a post installation action
  6.                 atom.  In the selector field, pass in the name of the target 'infs'
  7.                 resource id.  The code resource gets the resource, converts the partial
  8.                 path name field to a pascal string, then calls, SetFLock.  A result of 
  9.                 true is always returned so as not to abort the installation.
  10.         
  11.                 This action atom is designed for use by both Installer 3.2 and 3.3
  12.  
  13.     Written by: Rich Kubota    
  14.  
  15.     Copyright:    Copyright © 1990-1999 by Apple Computer, Inc., All Rights Reserved.
  16.  
  17.                 You may incorporate this Apple sample source code into your program(s) without
  18.                 restriction. This Apple sample source code has been provided "AS IS" and the
  19.                 responsibility for its operation is yours. You are not permitted to redistribute
  20.                 this Apple sample source code as "Apple sample source code" after having made
  21.                 changes. If you're going to re-distribute the source, we require that you make
  22.                 it clear in the source that the code was descended from Apple sample source
  23.                 code, but that you've made changes.
  24.  
  25.     Change History (most recent first):
  26.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  27.                 
  28.  
  29. */
  30.  
  31. #if 0
  32.  
  33. C -r -b  SetLockBit.c
  34. Link -ra =resPurgeable -t rsrc -c RSED -rt infn=10000 ∂
  35.     -m SETLOCKBIT -sg SetLockBit ∂
  36.     SetLockBit.c.o ∂
  37.     "{Libraries}"Interface.o ∂
  38.     -o SetLockBit.rsrc
  39.  
  40. #endif
  41.  
  42. #include <Types.h>
  43. #include <Resources.h>
  44. #include <Files.h>
  45. #include "ActionAtomIntf.h"
  46.  
  47. /* define record structure of 'infs' resource so that we can access the target file path */
  48.  
  49. struct infsRec {
  50.     long    fileType;
  51.     long    creator;
  52.     long    creationDate;
  53.     short    fileSpecFlags;
  54.     Str255    pathName;
  55. };
  56.  
  57. typedef struct infsRec infsRec;
  58. typedef infsRec **infsHdl;
  59.  
  60. /* protoypes */
  61. void    makePStr(char *fm, char *to);
  62.  
  63.  
  64. pascal Boolean    SETLOCKBIT(AAPBRecPtr myAAPBPtr)
  65. {
  66.     OSErr    err;
  67.     infsHdl    resH;
  68.     
  69.     resH = (infsHdl)GetResource('infs', myAAPBPtr->aaRefCon);
  70.     if (resH)
  71.         err = SetFLock((*resH)->pathName, myAAPBPtr->targetVRefNum);
  72.     return true;
  73. }
  74.